package com.learn.design.lsp.v1;

/**
 * 士兵
 *
 * @author Administrator
 */
public class Soldier {

    /**
     * 定义士兵的枪支
     */
    private AbstractGun gun;

    /**
     * 给士兵一支枪
     *
     * @param gun
     */
    public void setGun(AbstractGun gun) {
        this.gun = gun;
    }

    public void killEnemy() {
        if (gun instanceof AbstractToy){
            System.out.println("士兵开始玩玩具...");
        }else {
            System.out.println("士兵开始杀敌人...");
        }
        gun.shoot();
    }
}
